<template>
  <div class="meizhuang_main">
    <Advert></Advert>
    <Gridview
    :home10list = "home10list"
    ></Gridview>
    <Newlist
    :home7list = 'home7list'
    :home47list = "home47list"
    v-on:commonId='todetail'
    ></Newlist>

  </div>
</template>

<script>

  import Advert from "@/makeup/advert"
  import Gridview from "@/makeup/grid"
  import Newlist from "@/makeup/newlist"

  import Vue from 'vue'
  import { Grid, GridItem ,} from 'vant'
  import axios from 'axios'

  import _ from 'lodash'

  Vue.use(Grid);
  Vue.use(GridItem);


export default {
  methods: {
    todetail(commonId){
      this.$emit('commonId',commonId)
    }
  },
    data(){
      return{
        //home10总的数据
          home10list :[],
          home7list :[],
          home47list :[],

         
        
      }
  },
  components: {
    Advert,
    Gridview,
    Newlist
  },
  created () {
    axios({
        url : 'https://api.10street.cn/api/special?specialId=20&token=&_=1594127406815'
    }).then((result) => {  
    //ajax取得值
    let  itemlist = result.data.datas.itemList
    
    //console.log(itemlist)
    let i = 0;

    let  coming = _.groupBy(itemlist, (value) => {
      return value.itemType
    })
  // console.log(coming)   
    for ( let item  in coming){
      //home10 图片 grid
      if(item == "home10"){   
        for ( let data  in coming[item]){                    
            this.home10list.push(coming[item][data].itemData)     
            }
      } else if(item == "home7"){
        for ( let data  in coming[item]){                    
            this.home7list.push(coming[item][data].itemData)     
            }
      } else if(item == "home47"){
        for ( let data  in coming[item]){                    
            this.home47list.push(coming[item][data].itemData)     
            }
      } 
      
    }   
 // console.log( this.home10list)
   // console.log(this.home7list)
  //console.log(this.home47list)
   

    })
}

}
</script>

<style lang="stylus" scoped>

  
</style>